package com.own.component.common.base.entity.po;

import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.own.component.common.login.user.BaseLoginUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.FieldNameConstants;

import java.io.Serializable;

/**
 * BaseWithoutMemoPo
 *
 * @author chenxueli
 * @date 2024-01-13 14:03:41
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
public abstract class BaseWithoutMemoPo extends BaseModifiedPo implements Serializable {

    @JsonIgnore
    @TableLogic(value = "0", delval = "1")
    @Schema(title = "是否删除")
    private Integer isDeleted;

    @Schema(title = "数据版本号")
    @Version
    private Integer version;

    /**
     * 设置初始化信息
     */
    @Override
    public void init() {
        super.init();
        if (this.isDeleted == null) {
            this.isDeleted = 0;
        }
        if (this.version == null) {
            this.version = 0;
        }
    }

    /**
     * 设置初始化信息
     *
     * @param loginUser 登录用户对象
     */
    @Override
    public void init(BaseLoginUser loginUser) {
        super.init(loginUser);
        if (this.isDeleted == null) {
            this.isDeleted = 0;
        }
        if (this.version == null) {
            this.version = 0;
        }
    }

}
